package com.taiji.dianthus.dao.app;

import com.taiji.dianthus.domain.app.AppInfo;
import com.taiji.dianthus.domain.sys.SysLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @InterfaceName SysLogRepository
 * @Description 日志
 * @Author H.M
 * @Date 2020/6/22
 */
@Repository
public interface AppInfoRepository extends JpaRepository<AppInfo, String>,
        JpaSpecificationExecutor<AppInfo> {


    @Modifying
    @Transactional
    @Query("update AppInfo  set enableFlag=0 where id=:id")
    void updateFlag(@Param("id") String id);

    @Query("select t from AppInfo t where t.enableFlag=1 and  t.appName =:appName ")
    List<AppInfo> getByAppNameByAdd(@Param("appName") String appName);

    @Query("select t from AppInfo t where  t.enableFlag=1 and  t.appName =:appName and t.id<> :id")
    List<AppInfo> getByAppNameByEdit(@Param("appName") String appName, @Param("id") String id);

    @Query("select t from AppInfo t where t.enableFlag=1 and  t.appName=:appName")
    AppInfo getAppInfoByAppName(@Param("appName") String appName);

    @Query("select t from AppInfo t where t.enableFlag=1 and  t.id=:appId")
    AppInfo getAppInfoByAppId(@Param("appId") String appId);
}
